package com.chuanjiabao.wisdom.guide;

import android.app.Activity;
import android.view.View;

import com.blog.www.guideview.Component;
import com.blog.www.guideview.GuideBuilder;
import com.chuanjiabao.wisdom.listener.OnBHClickListener;

/**
 * 项目名称：chuanjiabao_android
 * 创建人：小卷毛
 * 创建时间：2019-11-14 14:51
 */
public class ComponentUtil {

    public static void showEndGuide(
            Activity activity,
            int resId,
            String title,
            String hint,
            View view,
            FunctionGuide function
    ) {
        EndComponent endComponent = new EndComponent();
        if (title != null) endComponent.setTitle(title);
        if (hint != null) endComponent.setHint(hint);
        if (resId > -1) endComponent.setImage(resId);
        endComponent.setOnBHClickListener(new OnBHClickListener() {
            @Override
            public void onConfirmClick() {
                function.invoke();
            }
        });

        new GuideBuilder()
                .setTargetView(view)
                .setAlpha(150)
                .setHighTargetGraphStyle(Component.CIRCLE)
                .setAutoDismiss(false)
                .setOutsideTouchable(false)
                .addComponent(endComponent)
                .createGuide()
                .show(activity);
    }

    public static void showStartGuide(
            Activity activity,
            int resId,
            String title,
            String hint,
            int offset,
            View view,
            FunctionGuide function
    ) {
        StartComponent startComponent = new StartComponent();
        if (title != null) startComponent.setTitle(title);
        if (hint != null) startComponent.setHint(hint);
        if (resId > -1) startComponent.setImage(resId);
        startComponent.setXOffset(offset);
        startComponent.setOnBHClickListener(new OnBHClickListener() {
            @Override
            public void onConfirmClick() {
                function.invoke();
            }
        });

        new GuideBuilder()
                .setTargetView(view)
                .setAlpha(150)
                .setHighTargetCorner(5)
                .setAutoDismiss(false)
                .setOutsideTouchable(false)
                .addComponent(startComponent)
                .createGuide()
                .show(activity);
    }

    public static void showStartCircelGuide(
            Activity activity,
            int resId,
            String title,
            String hint,
            int offset,
            View view,
            FunctionGuide function
    ) {
        StartComponent startComponent = new StartComponent();
        if (title != null) startComponent.setTitle(title);
        if (hint != null) startComponent.setHint(hint);
        if (resId > -1) startComponent.setImage(resId);
        startComponent.setXOffset(offset);
        startComponent.setOnBHClickListener(new OnBHClickListener() {
            @Override
            public void onConfirmClick() {
                function.invoke();
            }
        });

        new GuideBuilder()
                .setTargetView(view)
                .setAlpha(150)
                .setHighTargetGraphStyle(Component.CIRCLE)
                .setAutoDismiss(false)
                .setOutsideTouchable(false)
                .addComponent(startComponent)
                .createGuide()
                .show(activity);
    }

    public static void showCenterGuide(
            Activity activity,
            View view
    ) {
        new GuideBuilder()
                .setTargetView(view)
                .setAlpha(150)
                .setAutoDismiss(false)
                .setOutsideTouchable(false)
                .addComponent(new CenterComponent())
                .createGuide()
                .show(activity);
    }

}
